﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Group3.MediaTool.Interface
{
    public static class OrmExtension
    {
        public static Group3.MediaTool.Interface.IObjectRelationModel Instantiate<T>(this T newItm, params object[] parameter) where T: IObjectRelationModel
        {
            try
            {
               
                return ((IObjectRelationModel)newItm.GetType().GetConstructor(parameter != null?
                    (from c in parameter.AsEnumerable()
                        select c.GetType()).ToArray() 
                        :new Type[] { }).Invoke(parameter));
            }
            catch
            {
                return null;
            }
        }
    }
}
